package com.pisolution.scheduler.runtime.master.processor;

import com.pisolution.scheduler.core.utils.JsonUtils;
import com.pisolution.scheduler.remote.command.Command;
import com.pisolution.scheduler.remote.command.CommandConverter;
import com.pisolution.scheduler.remote.command.CommandType;

/**
 * 用于管理节点告知工作节点任务确认指令已经处理并更改了数据库中任务实例的状态.
 *
 * @author sora
 * @version 0.1.0
 */
public final class DBAckCommand implements CommandConverter {
    private static final long serialVersionUID = -204079456146451711L;

    // -------------------------------------------------------------------------------------------------

    /** 任务实例标识. */
    private int taskId;

    /** 指令处理状态. */
    private int status;

    // -------------------------------------------------------------------------------------------------
    //  属性访问
    // -------------------------------------------------------------------------------------------------

    public int getTaskId() {
        return this.taskId;
    }

    public void setTaskId(int taskId) {
        this.taskId = taskId;
    }

    public int getStatus() {
        return this.status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    // -------------------------------------------------------------------------------------------------
    //  指令转换
    // -------------------------------------------------------------------------------------------------

    @Override
    public Command convert() {
        final Command command = new Command();

        command.setType(CommandType.DB_ACK_REQUEST);
        command.setBody(JsonUtils.serialize(this));

        return command;
    }
}
